package com.piusvelte.btauto;

import static android.content.Intent.ACTION_BOOT_COMPLETED;
import static android.content.Intent.ACTION_PACKAGE_REPLACED;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;

public class BootReceiver extends BroadcastReceiver {

	@Override
	public void onReceive(Context context, Intent intent) {
		if (intent.getAction().equals(ACTION_BOOT_COMPLETED) || intent.getAction().equals(ACTION_PACKAGE_REPLACED) || intent.getAction().equals("android.intent.action.EXTERNAL_APPLICATIONS_UNAVAILABLE")) {
			if ((context.getSharedPreferences(context.getString(R.string.key_preferences), BtAutoService.MODE_PRIVATE)).getBoolean(context.getString(R.string.key_enableservice), false)) {
				WakeLockManager.acquire(context);
				context.startService(new Intent(context, BtAutoService.class));
			}
		}
	}

}
